var gamejs = require('gamejs');

/**
 * RADAR: an object representing a radar. The detection area is a circular sector.
 * 
 * Properties
 * - currentMatch : the match where the radar work.
 * - center : coordinates of the radar's position;
 * - centralAngle : angle covered by the radar (central angle of the circular sector);
 * - startAngle :  angle where the detection starts;
 * - currentAngle :  current angle into the circular sector;
 * - radius : max distance of detection (the radius of the circular sector);
 * - currentRadius : actual distance of detection, useful in several drawing problem;
 * - angularVelocity : number of radians that the detector ray covers in a second;
 * - level : the upgrade level of the radar;
 * - upgradeList : a list containing all the upgrade info for each upgrade level;
 * - resaleValue : the radar's remaining price;
 * - image : a Surface object with the radar's picture;
 */
 
 /**
 * Create a Radar object.
 * 
 * @param {Match} match The match where this object will work.
 * @param {[number, number]} coords The radar's position, in format [x, y].
 */
var Radar = exports.Radar = function(match, coords) {
	Radar.superConstructor.apply(this, arguments);
	this.currentMatch = match;
	this.center = coords;
	this.centralAngle = 2 * Math.PI;
	this.startAngle = 0;
	this.currentAngle = 0;
	this.currentRadius = this.radius;
	this.level = 0;
	this.upgradeList = [
	{ price : 100, radius : 100, angularVelocity : Math.PI / 2, resaleValue : 70 }, //livello 0
	{ price : 75, radius : 200, angularVelocity : Math.PI, resaleValue : 100 } //livello 1
	];
	
	this.image = gamejs.image.load('resources/images/sat.png');
}

/**
 * Radar extend Sprite.
 */
gamejs.utils.objects.extend(Radar, gamejs.sprite.Sprite);

/**
 * Return the match where this radar work.
 *
 * @param {Match} The match where this radar work.
 */
Radar.prototype.getMatch= function() {
	return this.currentMatch;
}

/**
 * Sets the angle where the detection starts.
 *
 * @param {number} angle The angle where the detection starts
 * @throws {TypeError} Throws this exception if angle's type isn't 'number'.
 */
Radar.prototype.setStartAngle = function(angle) {}

/**
 * Sets the angle covered by the radar.
 *
 * @param {number} angle The angle covered by the radar.
 * @throws {TypeError} Throws this exception if angle's type isn't 'number'.
 * @throws {RangeError} Throws this exception if angle's value isn't valid.
 */
Radar.prototype.setCentralAngle = function(angle) {}

/**
 * Triggers a radar's upgrade.
 */
Radar.prototype.upgrade = function() { }

/**
 * Updates the position of the detector ray of the radar.
 * 
 * @param {number} msDuration The time past from the last call, in ms.
 */
Radar.prototype.update = function(msDuration) {}

/**
 * Draws the radar in the given Surface.
 * 
 * @param {gamejs.Surface} surface The Surface where draw on.
 */
Radar.prototype.draw = function(surface) {}